﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Dao;
using Domain.Officers;

namespace Domain
{
    /// <summary>
    /// 职称
    /// </summary>
    public partial class OfficialPosition
    {
       public static Dictionary<short, OfficialPosition> OPositions = new Dictionary<short, OfficialPosition>();
       public short Id { get; set; }
       public string Name { get; set; }
       /// <summary>
       /// 达标功绩
       /// </summary>
       public int Performance { get; set; }
       /// <summary>
       /// 职称类型。0爵位，1官职
       /// </summary>
       public short Type { get; set; }
       /// <summary>
       /// 职位分类。1文职，2武职
       /// </summary>
       public short Category { get; set; }
       /// <summary>
       /// 是否可以授予多人
       /// </summary>
       public bool IsMutilate { get; set; }
       /// <summary>
       /// 最大授予人数
       /// </summary>
       public int MaxCount { get; set; }
       /// <summary>
       ///上级机构
       /// </summary>
       public short ParentId { get; set; }
       /// <summary>
       /// 官阶
       /// </summary>
       public string Level { get; set; }
       /// <summary>
       /// 薪水
       /// </summary>
       public int Salary { get; set; }
       /// <summary>
       /// 政治加成
       /// </summary>
       public short PoliticsAdd { get; set; }
       /// <summary>
       /// 统帅加成
       /// </summary>
       public short CommanderAdd { get; set; }
       /// <summary>
       /// 描述
       /// </summary>
       public string Description { get; set; }
       /// <summary>
       /// 当前拥有此官职的武将
       /// </summary>
       public List<Officer> CurrentOfficers=new List<Officer>();
       public static void Load()
       {
           if (OPositions.Count > 0)
               return;
           DataTable tb = OfficialPositionDao.SelectAllOfficialPosition("194_QXGJ.s3db");
           for (int i = 0; i < tb.Rows.Count; i++)
           {
               DataRow dr = tb.Rows[i];
               OfficialPosition s = new OfficialPosition();
               s.Id = Convert.ToInt16(dr["Id"]);
               s.Name = dr["Name"].ToString();
               s.IsMutilate = Convert.ToBoolean(dr["IsMutilate"]);
               s.MaxCount = Convert.ToInt32(dr["MaxCount"]);
               s.ParentId = Convert.ToInt16(dr["ParentId"]);
               s.Level = dr["Level"].ToString();
               s.Performance = Convert.ToInt32(dr["Performance"]);
               s.Type = Convert.ToInt16(dr["Type"]);
               s.Category = Convert.ToInt16(dr["Category"]);
               s.Salary = Convert.ToInt32(dr["Salary"]);
               s.PoliticsAdd = Convert.ToInt16(dr["PoliticsAdd"]);
               s.CommanderAdd = Convert.ToInt16(dr["CommanderAdd"]);
               s.Description = dr["Description"].ToString();
               OPositions.Add(s.Id, s);
           }
       }
    }
}
